package com.yonyou.iuap.activiti.demo.test;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.junit.Test;

/**
 * @author guoxh alias 灰太狼(wolffy)
 * @Date 2019/7/3 9:38
 * @desc com.yonyou.iuap.activiti.demo.test
 *
 * 通过TaskListener监听配置的流程,需要手动修改bpmn文件,将event="create" 放在class前面,且把不需要配置的节点删除
 */
public class ActivitiDynamicDemo {

    @Test
    public void deployFlow(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getRepositoryService().createDeployment()
                .addClasspathResource("qingjia3.bpmn")
                .addClasspathResource("qingjia3.png")
                .deploy();
        System.out.println("流程加载完毕");
    }


    @Test
    public void startFlow(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getRuntimeService().startProcessInstanceById("请假流程3:1:70004");
    }

    @Test
    public void startTeacherFlow(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getTaskService().complete("72504");
    }

    @Test
    public void startManagerFlow(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getTaskService().complete("75002");
    }

    @Test
    public void finishFlow(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getTaskService().complete("77502");
    }
}
